
/*
 *@author lwh created
 *
 *
 *
 */
#include "thread_pool.h"
#include "user.h"
#include "linked_list.h"
#include "str_util.h"
extern ListNode* userList;

void pwdCommand(task_t * task)
{
    printf("execute pwd command.\n");
    //获取当前工作目录并存入用户信息结构体
    ListNode* curuser = userList;
    char cwd[256];
    
    if(!((user_info_t*)curuser->val)->pwd){
        error(1,0,"pwd");
    }
    char buff[128]={0};
    strcpy(buff,((user_info_t*)curuser->val)->pwd);
    splitDir(buff,"/");
    printf("分割之后的cwd,发回给客户端的结果是 = %s\n",buff);
    printf("current work directory  = %s\n",((user_info_t*)curuser->val)->pwd);
    send(task->peerfd,buff,sizeof(buff),0);
    

    //char buff[256]={0};
    //if(getcwd(buff,sizeof(buff))==NULL){
    //    error(1,0,"pwd");
    //}
    
    //在服务端打印当前工作目录
    //printf("pwd = %s",buff);
    
    //获取路径后要发送给客户端
    //send(task->peerfd,buff,sizeof(buff),0);
    return;
}
